#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
double dis[100005][2];
double moni[100005];
bool cars[100005];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen("detect.in","r",stdin);
    /reopen("detect.out","w",stdout);
    int T;
    cin>>T;
    int n,m,L,V,d,v,a;
    for(int k = 1; k <= T; k++)
    {
        cin>>n>>m>>L>>V;
        for(int i = 1; i <= n; i++)
        {
            cin>>d>>v>>a;//v:starting speed    a:adding speed
            if (v > V){
                if(a >= 0)
                {
                    dis[i][0] = d*1.0;
                    dis[i][1] = L*1.0+0.1;
                }
                if(a < 0)
                {
                    dis[i][0] = d*1.0-0.1;
                    dis[i][1] = abs((v*v - V*V) / (2.0 * a)) + d * 1.0-0.1;
                }
            }
            if(v <= V)
            {
                if(a < 0)dis[i][0] = dis[i][1] = -1.0;
                if(a >= 0)
                {
                    double md = abs((V*V - v*v) / (2.0 * a));//moving distance when speed == SPEED
                    if(d + md <= L)
                    {
                        dis[i][0] = d + md+0.1;
                        dis[i][1] = L*1.0 + 0.1;
                    }
                    if(d + md > L)
                    {
                        dis[i][0] = dis[i][1] = -1.0;
                    }
                }
            }
        }
        int ans = 0;
        for(int i = 1; i <= m; i++)
            cin>>moni[i];
        int sum = 0;
        for(int i = 1; i <= m; i++)
        {
            for(int j = 1; j <= n; j++)
                if(dis[j][0] <= moni[i] && dis[j][1] > moni[i])
                {
                    cars[j] = true;

                }
        }

        int cnt = 0;
        for(int i = 1; i <= n; i++)
        {
            if(cars[i])cnt++;
        }

        cout<<cnt<<' '<<m/2+1<<endl;
    }
    return 0;
}
